<template>
	<view>
		<view class="main">
			<view class="subject">抽奖结果</view>
			<view class="body">
				<maoScroll :data="data" :showNum="showNum" :lineHeight="lineHeight" :animationScroll="animationScroll" :animation="animation">
					<template v-slot="{line}">
						<view class="line">{{line.author}} 获得 {{line.subject}}</view>
					</template>
				</maoScroll>
			</view>
		</view>
		<view class="main">
			<view class="subject">滑动配置</view>
			<view class="body">
				<view><text>数据总数：</text><text>{{count}}条（模拟）</text></view>
				<view><text>显示条数：</text><text>{{showNum}}条</text></view>
				<view><text>每行高度：</text><text>{{lineHeight}}rpx</text></view>
				<view><text>滑动时间：</text><text>{{animationScroll}}毫秒</text></view>
				<view><text>滑动间隔：</text><text>{{animation}}毫秒</text></view>
			</view>
		</view>
	</view>
</template>

<script>
	import maoScroll from '@/components/mao-scroll/mao-scroll.vue';
	export default {
		components:{
			maoScroll
		},
		data() {
			return {
				title: 'Hello',
				data: [],
				count: 30,
				showNum: 5,
				lineHeight: 60,
				animationScroll: 800,
				animation: 2000,
			}
		},
		onLoad() {
			console.log('init');
			console.log(this.data, '初始化数据 空数据');
			let self = this;
			setTimeout(function(){
				console.log('模拟从网上获取数据 花费了1秒');
				self.createData();
				console.log(self.data, '获取到的数据');
			}, 1000);
		},
		methods: {
			createData: function(){
				for(let i = 1; i <= this.count; i++){
					this.data.push({
						author: 'MaoUI',
						subject: 'OnePlus手机 * ' + i + '部'
					})
				}
			}
		}
	}
</script>

<style>
	.main{margin:30rpx;background-color: #FF6700;border-radius: 10rpx;border:1px solid #FF6700;}
	.main .subject{height: 80rpx;font-size: 36rpx;text-align: center;line-height: 80rpx;color: #fff;}
	.main .body{padding: 20rpx;background-color: #FFFFFF;}
	.main .body .line{height: 60rpx;line-height: 60rpx;}
</style>
